package com.carleasoft.mps.core.result;

import com.carleasoft.mps.core.constant.ErrorInfoEnum;

/**
 * @program:
 * @description:
 * @author: ztm
 * @create time: 2019/11/12 16:26
 **/
public class ResultBody<T> {
    /**
     * 响应代码
     */
    private String code;

    /**
     * 响应消息
     */
    private String message;

    /**
     * 响应结果
     */
    private T data;

    public ResultBody(ErrorInfoEnum errorInfo) {
        this.code = errorInfo.getCode();
        this.message = errorInfo.getMessage();
        this.data = null;
    }

    public ResultBody(ErrorInfoEnum errorInfo, T data) {
        this.code = errorInfo.getCode();
        this.message = errorInfo.getMessage();
        this.data = data;
    }

    public ResultBody(T result) {
        this.code = ErrorInfoEnum.SUCCESS.getCode();
        this.message = ErrorInfoEnum.SUCCESS.getMessage();
        this.data = result;
    }
    public ResultBody(String code, String message){
        this.code = code;
        this.message = message;
        this.data =null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
    
}
